<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
         
        <ui:define name="content">
             <br />
             
              
             <h:form prependId="false">
            <p:panel  header="#{rawMaterialRequirementWeeklyEntityController.selected.rawMaterial.productName} Material Requirement Plans for Year #{rawMaterialRequirementWeeklyEntityController.selected.yearOfProduction} (#{rawMaterialRequirementWeeklyEntityController.selected.monthOfProduction})" id="MRPs" toggleable="true">
               
                    <h:panelGroup id="mrpPanel" layout="block">
                        <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                    </h:panelGroup>
                    
                   
                    
                        
                         <h:panelGroup >
                        <h:panelGrid columns="2">
                      
                       <h:outputLabel value="Previous Month On Hand(Kg) :" for="previousOnHand" />
                       <h:outputLabel value="#{rawMaterialRequirementWeeklyEntityController.previousMonthOnHand}"/>
                        </h:panelGrid>
                        <p:dataTable value="#{rawMaterialRequirementWeeklyEntityController.mrpsThisMonthForThisRawMaterial}" var="item" 
                                     style="text-align: center"
                                     paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15">
<!--                                    selection="#{rawMaterialRequirementWeeklyEntityController.selected}" selectionMode="single"
                                     rowSelectListener="#{rawMaterialRequirementWeeklyEntityController.listMrpsThisMonthForThisMaterial(item)}">-->
                                     

                            
                            <p:column sortBy="#{item.weekOfProduction}">
                                <f:facet name="header">
                                    <h:outputText value="Week"/>
                                </f:facet>
                                <h:outputText value="#{item.weekOfProduction}"/>
                            </p:column> 
                            
                             <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Gross Requirements(kg)"/>
                                </f:facet>
                                <h:outputText value="#{item.grossRequirement}"/>
                            </p:column>
                            
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Scheduled Receipts(kg)"/>
                                </f:facet>
                                <h:outputText value="#{item.scheduledReceipt.quantity}"/>
                            </p:column>
                            
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Planned Receipts(kg)"/>
                                </f:facet>
                                <h:outputText value="#{item.plannedReceipt}"/>
                            </p:column>
                            
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="On Hand(kg)"/>
                                </f:facet>
                                <h:outputText value="#{item.onHandQuantity}"/>
                            </p:column>
                            
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Planned Orders(kg)"/>
                                </f:facet>
                                <h:inputText value="#{item.plannedOrderQuantity}" validator ="#{rawMaterialRequirementWeeklyEntityController.validatePlannedOrder}"/>
                            </p:column>
                            
<!--                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="IsLastWeek"/>
                                </f:facet>
                                <h:inputText value="#{item.isLastWeek}"/>
                            </p:column>-->
                            
                            <p:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                                  

                            <p:commandButton image="ui-icon ui-icon-search" update="display" oncomplete="recommendPlanOrderDialog.show()">
                                <f:setPropertyActionListener value="#{item}"  
                                                             target="#{rawMaterialRequirementWeeklyEntityController.current}" /> 
                            </p:commandButton>
                            </p:column>
                            
                           
                        </p:dataTable>   

                           
                    </h:panelGroup>
                 <p:dialog header="Recieving Week Detail" widgetVar="recommendPlanOrderDialog" resizable="false"  
                          width="325" showEffect="explode" hideEffect="explode">    
                    <h:panelGrid id="display" columns="2">
                         <h:outputText value="Recieving Year"/>
                         <h:outputText value="#{rawMaterialRequirementWeeklyEntityController.recievingWeek.yearOfProduction}"/>
                         <h:outputText value="Recieving Month"/>
                         <h:outputText value="#{rawMaterialRequirementWeeklyEntityController.recievingWeek.monthOfProduction}"/> 
                         <h:outputText value="Recieving Week"/>
                         <h:outputText value="#{rawMaterialRequirementWeeklyEntityController.recievingWeek.weekOfProduction}"/> 
                         <h:outputText value="Gross Requirement"/>
                         <h:outputText value="#{rawMaterialRequirementWeeklyEntityController.recievingWeek.grossRequirement}"/> 
                    </h:panelGrid>
                    </p:dialog> 
                    <br />
                    <p:commandButton action="#{rawMaterialRequirementWeeklyEntityController.updateMRPs}" 
                                 value="Update MRPs"
                                 update="@form:MRPs"/>
                
            </p:panel>
             </h:form> 
             
             <br/>
             <p:panel toggleable="true" id="materialInfo" header="Raw Material Information">
                 <h:panelGroup >
                        <h:panelGrid columns="2">
                      
                    <h:outputLabel value="Raw Material Name :" for="productName" />
                    <h:outputLabel value="#{rawMaterialRequirementWeeklyEntityController.selected.rawMaterial.productName}"/>
                    
                    <h:outputLabel value=" Lot Size (Kg) :" for="lotSize" />
                    <h:outputLabel value="#{rawMaterialRequirementWeeklyEntityController.selected.rawMaterial.lotSize}" />
                    
                    <h:outputLabel value=" Shelf Life (Month) :" for="shelfLife" />
                    <h:outputLabel  value="#{rawMaterialRequirementWeeklyEntityController.selected.rawMaterial.shelfLife}" />
                    
                    <h:outputLabel value=" Lead Time (Week) :" for="leadTime" />
                    <h:outputLabel  value="#{rawMaterialRequirementWeeklyEntityController.selected.rawMaterial.leadTime}" />
                       </h:panelGrid>
                    </h:panelGroup>
                    <br/>
             </p:panel>
            <h:form>
            <p:commandButton rendered="#{loginBacking.createNewMRP}" action="#{rawMaterialRequirementWeeklyEntityController.prepareCreate}" ajax="false" value="Create New Material Requirement Plan"/>
            <p:commandButton value="Back" action="/entities/rawMaterialRequirementWeeklyEntity/ListMrpsThisMonth?faces-redirect=true" />
            </h:form>
        </ui:define>
    </ui:composition>

</html>
